public abstract class CashMethod : Object {

	public abstract double calc_cash(double cash);	
}

public class CashNormal : CashMethod {

	public override double calc_cash(double cash) {
		return cash;
	}
}

public class CashDiscount : CashMethod {
	
	public double discount { get; construct; }

	public CashDiscount(double discount) {
		Object(discount : discount);
	}
	
	public override double calc_cash(double cash) {
		
		return cash * discount;
	}
}

public class CashReturn : CashMethod {

	public double condition { get; construct; }
	public double cash_return { get; construct; }
	
	public CashReturn(double condition, double cash_return) {
		Object(condition : condition, cash_return : cash_return);
	}
	
	public override double calc_cash(double cash) {
		
		return (cash - ((int)(cash / condition) * cash_return));
	}
}

public class Cashier : Object {

	private CashMethod method;
	
	public Cashier(string type) {
		switch(type) {
			case "无折扣":
				method = new CashNormal();
				break;
				
			case "80%":
				method = new CashDiscount(0.8);
				break;
				
			case "满300减50":
				method = new CashReturn(300, 50);
				break;
				
			default:
				assert_not_reached();
				break;
		}
	}
	
	public double get_result(double cash) {
		return method.calc_cash(cash);
	}
}
